﻿@{
    Layout = null;

}
@model Spacebuilder.Setup.UpgradeInfoModel
<!doctype html>
<html class="no-js" lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="IE=edge, chrome=1">
    <title>升级向导</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../css/bootstrap.css">
    <link rel="stylesheet" href="../css/font-awesome.css">
    <!--框架样式-->
    <link rel="stylesheet" href="../css/tnui.css">
    <link rel="stylesheet" href="../css/jh-install.css">
    <script type="text/javascript" src="../js/modernizr-2.8.3.min.js"></script>
    <script type="text/javascript" src="../js/jquery-1.12.0.min.js"></script>
    <script type="text/javascript" src="../js/main.js"></script>
    <script type="text/javascript" src="../js/lib/jquery.livequery.js"></script>
    <script type="text/javascript" src="../js/lib/ajaxForm/jquery.form.js"></script>
    <script type="text/javascript" src="../js/lib/layer/layer.js"></script>
    <link rel="stylesheet" href="../js/lib/layer/skin/tnui/style.css">
    <script src="~/js/lib/jquery-validation/dist/jquery.validate.min.js"></script>


    <!--[if lt IE 9]>
    <script type="text/javascript" src="../js/html5shiv.min.js"></script>
    <script type="text/javascript" src="../js/respond.js"></script>
    <![endif]-->
    <style type="text/css">
        input:-webkit-autofill, select:-webkit-autofill, textarea:-webkit-autofill {
            -webkit-box-shadow: 0 0 0px 1000px #ffffff inset !important;
        }
    </style>
</head>
<body>
    <div class="tn-doc">
        <div class="tn-content">
            <div class="container">
                <div class="jh-install-logo">
                    <img alt="..." src="../img/logo-big.png" width="124">
                    <span class="jh-install-wizard"> v5.2 升级向导</span>
                </div>

                <div class="jh-install-block">

                    <div class="jh-install-content"  style="height:500px">
                       @using(Html.BeginForm("Upgrade_Start3", "Upgrade", FormMethod.Post, new { @id = "Upgrade2Form", @class = "form-horizontal tn-form-validation" }))
                       {
                           @Html.AntiForgeryToken()
                           @Html.HiddenFor(n=>n.UpgradeModule)
                        @Html.HiddenFor(n => n.CurrentVersion)
                        <div class="form-group">
                            <label for="" class="col-xs-3 control-label">旧版数据库连接字符串</label>
                            <div class="col-xs-9">
                                @Html.TextBoxFor(n => n.OldConnectionStrings, new { @class = "form-control" })
                                @Html.ValidationMessageFor(n => n.OldConnectionStrings)
                                <span class="help-block tn-mb-0">可以从旧版web.config中获取 (例如:"< add name="SqlServer" connectionString= " server=192.168.0.20;uid=spb;pwd=123456;database=Spacebuilder" />")</span>
                            </div>

                        </div>
                        <div class="form-group">
                            <label for="" class="col-xs-3 control-label">旧版附件所在目录</label>
                            <div class="col-xs-9">
                                @Html.TextBoxFor(n => n.OldFilePath, new { @class = "form-control" })
                                @*<input type="file" name="fileString" multiple class="file">*@      
                                @Html.ValidationMessageFor(n => n.OldFilePath)
                                <span class="help-block tn-mb-0">如果未做修改,选择旧站点的"~/uploads"目录(例如："D:\wwwroot\近乎\Uploads" )</span>
                            </div>

                        </div>
                       }

                    </div>
                    <div class="form-inline tn-tool-column  pull-right  " >
                        <div class="form-group ">
                            <input id="Next" type="button" class="btn btn-primary   " value="下一步">
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <script type="text/javascript">
        //$("input[name=fileString]").change(function () {
        //    //var names = [];  

        //    for (var i = 0; i < $(this).get(0).files.length; ++i) {
        //        // names.push($(this).get(0).files[i].name);  
        //        //console.log($(this).get(0).files[i].mozFullPath);  
        //        //方式一：  
        //        var filePath = $(this).val();
        //        console.log(filePath);
        //        //方式二：  
        //        alert($('input[type=file]').val());
        //    }
        //    //console.log(names);  
        //    //方式三：  
        //    alert($("input[name=fileString]").val());

        //})

        var loadindex;
        var msgindex;
       $("#Next").click(function myfunction() {
         
           if ($("#OldConnectionStrings").val()=="") {
               layer.msg("请填写旧数据库连接串!", { icon: 2 });
               return false;
           }
           if ($("#OldFilePath").val() == "") {
               layer.msg("请填写旧版附件目录路径!", { icon: 2 });
               return false;
           }

           msgindex = layer.msg("程序升级中...<br>请耐心等待,中途请勿取消,以免数据丢失！", { icon: 8, time: 200000, shade: 0.1 });
           loadindex = layer.load();
           $.post("@CachedUrlHelper.Action("Upgrade_Start3", "Upgrade")", $("#Upgrade2Form").serialize(), function myfunction(data) {
               if (data.state) {
                   layer.msg(data.msg, { icon: 1 });

                   window.location.href = "@CachedUrlHelper.Action("Upgrade_End", "Upgrade")"
               } else {
                   layer.msg(data.msg, { icon: 2 });
               }
               layer.close(loadindex);
               layer.close(msgindex);
           });


        })


    </script>
</body>
</html>
